<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('入库单列表')"/>
    <style>
        .form-li li label:not(.radio-box) {
            float: left;
            width: 78px;
            margin: 5px 12px 0px 0px;
            text-align: right;
        }
    </style>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list form-li">
                    <ul>
                        <li>
                            <label>入库单号：</label>
                            <input type="text" name="entryOrderId"/>
                        </li>
                        <li>
                            <label>采购部门：</label>
                            <input type="text" name="procurementDepartment"/>
                        </li>
                        <li>
                            <label>使用部门：</label>
                            <input type="text" name="userDepartment"/>
                        </li>
                        <li>
                            <label>到货单号：</label>
                            <input type="text" name="deliveryId"/>
                        </li>
                        <li>
                            <label>业务员：</label>
                            <input type="text" name="salesman"/>
                        </li>
                        <li>
                            <label>工程项目：</label>
                            <input type="text" name="project"/>
                        </li>
                        <li>
                            <label>仓库：</label>
                            <input type="text" name="warehouse"/>
                        </li>
                        <li>
                            <label>采购经办人：</label>
                            <input type="text" name="purchaser"/>
                        </li>
                        <li>
                            <label>合同编号：</label>
                            <input type="text" name="contractId"/>
                        </li>
                        <li>
                            <label>审核员：</label>
                            <input type="text" name="reviewedBy"/>
                        </li>
                        <li>
                            <label>仓库主管：</label>
                            <input type="text" name="supervisor"/>
                        </li>
                        <li>
                            <label>仓管员：</label>
                            <input type="text" name="storekeeper"/>
                        </li>
                        <li>
                            <label>入库时间：</label>
                            <input type="text" class="time-input" placeholder="请选择入库时间" name="entryTime"/>
                        </li>
                        <li>
                            <label>供应商：</label>
                            <select name="supplierId" class="supplier-select"></select>
                        </li>
                        <li>
                            <label>物料编码：</label>
                            <input type="text" name="materialId"/>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-success" onclick="$.operate.addTab()"
               shiro:hasPermission="warehouse:warehousingEntry:add">
                <i class="fa fa-plus"></i> 添加
            </a>
            <a class="btn btn-warning" onclick="$.table.exportExcel()"
               shiro:hasPermission="warehouse:warehousingEntry:export">
                <i class="fa fa-download"></i> 导出
            </a>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: select2-css" />
<th:block th:include="include :: select2-js" />
<script th:inline="javascript">
    $('.supplier-select').select2({
        placeholder: '--请选择供应商--',
        ajax: {
            url: '/warehouse/supplier/selectList',
            delay: 250,
            data: function (params) {
                return {
                    supplierName: params.term
                };
            }
        }
    });

    var editFlag = [[${@permission.hasPermi('warehouse:warehousingEntry:edit')}]];
    var removeFlag = [[${@permission.hasPermi('warehouse:warehousingEntry:remove')}]];
    var prefix = ctx + "warehouse/warehousingEntry";

    $(function () {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            exportUrl: prefix + "/export",
            modalName: "入库单",
            detailView: true,
            onExpandRow: function (index, row, $detail) {
                initChildTable(index, row, $detail);
            },
            columns: [{
                checkbox: true
            }, {
                field: 'id',
                title: '主键',
                visible: false
            }, {
                field: 'entryOrderId',
                title: '入库单号'
            }, {
                field: 'procurementDepartment',
                title: '采购部门'
            }, {
                field: 'userDepartment',
                title: '使用部门'
            }, {
                field: 'deliveryId',
                title: '到货单号'
            }, {
                field: 'salesman',
                title: '业务员'
            }, {
                field: 'project',
                title: '工程项目'
            }, {
                field: 'warehouse',
                title: '仓库'
            }, {
                field: 'purchaser',
                title: '采购经办人'
            }, {
                field: 'contractId',
                title: '合同编号'
            }, {
                field: 'reviewedBy',
                title: '审核员'
            }, {
                field: 'supervisor',
                title: '仓库主管'
            }, {
                field: 'storekeeper',
                title: '仓管员'
            }, {
                field: 'entryTime',
                title: '入库时间'
            }, {
                field: 'supplierName',
                title: '供应商'
            }]
        };
        $.table.init(options);
    });

    initChildTable = function (index, row, $detail) {
        var childTable = $detail.html('<table style="table-layout:fixed"></table>').find('table');
        $(childTable).bootstrapTable({
            url: prefix + "/detailList/" + row.entryOrderId,
            method: 'get',
            sidePagination: "server",
            columns: [{
                field: 'materialId',
                title: '物料编号'
            }, {
                field: 'materialName',
                title: '物料名称'
            }, {
                field: 'entryNum',
                title: '入库数量'
            }, {
                field: 'unitPrice',
                title: '单价'
            }, {
                field: 'unit',
                title: '物料单位'
            }, {
                field: 'taxAmount',
                title: '税额'
            }, {
                field: 'totalPrice',
                title: '总价'
            }, {
                field: 'producer',
                title: '产地'
            }, {
                field: 'brand',
                title: '品牌'
            }]
        });
    };
</script>
</body>
</html>